package day12.DuiXiang.Lx;

import java.io.*;
import java.util.ArrayList;

public class Text2 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student s1=new Student("张三",23);
        Student s2=new Student("李四",23);
        Student s3=new Student("王五",23);
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("jinjie\\b.txt"));
        ArrayList<Student>list=new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        oos.writeObject(list);
        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("jinjie\\b.txt"));

        ArrayList<Student>list2= (ArrayList<Student>)ois.readObject();
        for (Student s : list2) {
            System.out.println(s);
        }
        oos.close();
        ois.close();
    }
}
